<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('商户图片资料')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>商户图片资料</h5>
                </div>
                <form id="form-img-add" onSubmit="return valiFile(this)"  method="post" action="/agentInfo/agentInfo/uploadImg" enctype="multipart/form-data">
                    <input type="hidden" id="agentNum" name="agentNum" th:value="${agentNum}">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="font-noraml">身份证正面:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input required  type="file" id="1" name="1"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">身份证反面:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="2" name="2"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">营业执照:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="5" name="5"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">开户许可证:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="16" name="16"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">门头照外景:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="7" name="7"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">门头照内景:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="6" name="6"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">服务商情况说明表:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="17" name="17"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">税务登记证:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="14" name="14"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="font-noraml">组织机构代码证:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input type="file" id="15" name="15"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <span style="color: #8a1f11" class="help-block m-b-none"><i class="fa fa-info-circle"></i> 税务登记证,组织机构代码证非必提交。</span>
        <span style="color: #8a1f11" class="help-block m-b-none"><i class="fa fa-info-circle"></i> 指定格式:png,jpg,bmp,jpeg</span>

    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:inline="javascript">
        var url = ctx + "agentInfo/agentInfo";
        function submitHandler() {
            //if (valiFile()) {
            var data = new FormData();
            //加入文件对象 需要自定义处理不是file类型的参数
            data.append("1", document.getElementById("1").files[0]);
            data.append("2", document.getElementById("2").files[0]);
            data.append("5", document.getElementById("5").files[0]);
            data.append("6", document.getElementById("6").files[0]);
            data.append("7", document.getElementById("7").files[0]);
            data.append("14", document.getElementById("14").files[0]);
            data.append("15", document.getElementById("15").files[0]);
            data.append("16", document.getElementById("16").files[0]);
            data.append("17", document.getElementById("17").files[0]);
            data.append("agentNum", $("#agentNum").val());
            $.ajax({
                url: url + "/uploadImg",
                data: data,
                type: "post",
                dataType: "json",
                cache: false,//上传文件无需缓存
                processData: false,//用于对data参数进行序列化处理 这里必须false
                contentType: false, //必须
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                },
                success: function (result) {
                    if (result.code == '0') {
                        $.operate.successCallback(result);
                    }else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                }
            })
        }

        /**
         * 验证图片上传
         */
        function valiFile() {
            //获取文本描述
            var textArray=new Array();
            $($('.font-noraml')).each(function(index){
                textArray.push($(this).text().replaceAll(":",''))
            });
            //错误选择描述
            $($('input[type="file"]')).each(function(index){
                if($('input[type="file"]').val() == "") {
                    $.modal.alertError("请上传" + textArray[index]);
                    return false;
                }
            });
            return true;
        }

    </script>
</body>
</html>
